Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

195
Views
Is there a way to render page only after updating infos ? | Ionic - React

I have some troubles with Async functions.
This is not the same as : This question

I'll do my best to explain. So I try to retrieve data from a Firebase Database.
I can upload data to the database without any problem. I can retrieve them too.

"So where is your issue ?" - probably you behind your screen

My issue is showing the data I retrieve from the database. Here is some code :

const [messages,setMessages] = useState<Message[]>([]);

  useIonViewWillEnter(() => {
    const msgs = getMessagesFromDB().then((data)=>{
      setMessages(data);
    });
   setBusy(false)
 });

And on another file :

export const getMessagesFromDB = async () : Promise<Message[]> => {
    const ref = await firebase.default.database().ref('message');
    try{
        ref.on('value', (snapshot) => {
            const data = snapshot.val();
            const current : Message = data['-Mv4-nZYSk9PoE_cwkWw'][0];
           
            setMessages(current);
            return current;
        });
    }catch (e) {
        throw e; 
    }
    return getMessages();
    
};

Here is my issue, if I do a console.log(data), I see my data from the database.
But I use messages on my page, and nothing show up:

 {busy ? <IonSpinner/> :  messages.map(m => <MessageListItem key={m.id} message={m} />)}

Do you know how can I wait for data ?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!